﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Globalization;
using System.Collections;
using StockTrader.DAL.HastcAdapter.FileParser.Structure;
using StockTrader.DAL.HastcAdapter.FileParser;

namespace StockTrader.DAL.HastcAdapter.FileMonitor.BusinessLogic
{
    public enum MarketState
    {
        BeginOfDay,
        Working,
        EndOfDay,
    }

    public class TransSchedule
    {
        public static MarketState getMarketState(STS_MARKETINFO item)
        {
            if (item.FLOOR_CODE==null)
                return MarketState.EndOfDay;
            if (item.FLOOR_CODE.Equals("02"))
            {
                if (item.CURRENT_STATUS.Equals(5))
                    return MarketState.Working;
                else
                    if (DateTime.Now.Hour < 10)
                        return MarketState.BeginOfDay;
            }
            return MarketState.EndOfDay;
        }

        public static bool IsTradingDate(STS_MARKETINFO item)
        {
            if (item.FLOOR_CODE.Equals("02"))
                if (item.TRADING_DATE.Date.Equals(DateTime.Now.Date))
                    return true;

            return false;
        }

        public static STS_MARKETINFO getMarketInfo()
        {            
            ArrayList list = FileEngineer.RetrieveFileInfo(typeof(STS_MARKETINFO));
            foreach (STS_MARKETINFO item in list)
                if (item.FLOOR_CODE.Equals("02"))
                    return item;
            return new STS_MARKETINFO();
        }
    }
}
